feat(sveltekit): Ensure AsyncLocalStorage async context strategy is used in Cloudflare Pages
#15557
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While investigating #15506, I noticed that we missed an important part when setting up the SDK via the
initCloudflareSentryHandlehook: We need to call@sentry/cloudflare'ssetAsyncLocalStorageAsyncContextStrategyfunction as otherwise, we don't get working request isolation.I decided to export
setAsyncLocalStorageAsyncContextStrategyfrom@sentry/cloudflareso that we could otherwise only callsentryPagesPluginand completely ignore the return value. Which isn't ideal as we add public API. However,initCloudflareSentryHandleis basically a SvelteKit-specific version ofSentryPagesPluginalready, so I think it's fine to just set the ACS in there as well.If reviewers prefer though, I think we can solve this in other ways:
setAsyncLocalStorageAsyncContextStrategyfrom@sentry/cloudflare/internalsentryPagesPluginand completely ignore the return typeHappy to make any of these changes.
Otherwise, the PR adds tests and refactors the test directory structure after #13142.
note:
featbecause public API is added to cloudflare package